package com.project_doctor.service.impl;

import com.project_doctor.pojo.Doctor;
import com.project_doctor.service.DoctorService;
import com.project_doctor.service.WebSocketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class WebSocketServiceImpl implements WebSocketService {

    @Autowired
    private DoctorService doctorService;

    @Override
    @Transactional
    public void processLogin(Long userId) {
        Doctor user = doctorService.getById(userId);
        if (!"ONLINE".equals(user.getStatus())) {
            user.setStatus("ONLINE");
            doctorService.updateById(user);
        }
    }
}
